import time

from selenium import webdriver
from selenium.webdriver.common.by import By

# 元素操作
def web_interaction():

    driver = webdriver.Chrome()
    # 2.open
    driver.get("https://www.sogou.com/")
    # 3.send
    driver.find_element(By.ID,"query").send_keys("霍格沃兹测试开发")
    time.sleep(2)
    # 4.clear
    driver.find_element(By.ID,"query").clear()
    time.sleep(2)
    # 5.send again
    driver.find_element(By.ID,"query").send_keys("霍格沃兹测试开发2")
    time.sleep(2)
    # 6.click
    driver.find_element(By.ID,"stb").click()
    time.sleep(2)

# 获取元素属性
def element_get_attr():
    driver = webdriver.Chrome()
    driver.get("https://vip.ceshiren.com/#/ui_study")
    web_element = driver.find_element(By.ID, "locate_id")
    print(web_element.text)
    print(web_element.get_attribute("id"))
    print(web_element.get_attribute("class"))



if __name__ == '__main__':
    # 元素操作
    # web_interaction()
    element_get_attr()

